package cs342.uwosh.edu.ContactsApp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import cs342.uwosh.edu.ContactsApp.*;

public class SettingsActivity extends Activity {
	private RadioGroup radioGroup;
	private RadioButton radioButton;
	private Button saveButton;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.settings);
		
		addListenerOnButton();
		
	}
	
	public void addListenerOnButton()
	{
		final Intent i = new Intent(this, ContactsActivity.class);
		radioGroup = (RadioGroup) findViewById(R.id.themeGroup);
		saveButton = (Button) findViewById(R.id.saveButton);
		
		saveButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				int selectedId = radioGroup.getCheckedRadioButtonId();
				
				radioButton = (RadioButton) findViewById(selectedId);
				
				String temp = (String)radioButton.getText();
				
				if(temp.equals("Light Theme"))
				{
					ContactsActivity.theme = 1;
					Toast.makeText(SettingsActivity.this, "Light Theme Saved", Toast.LENGTH_SHORT).show();
					startActivity(i);
				}
				else if(temp.equals("Matrix Theme"))
				{
					ContactsActivity.theme = 2;
					Toast.makeText(SettingsActivity.this, "Matrix Theme Saved", Toast.LENGTH_SHORT).show();
					startActivity(i);
				}
				else
				{
					ContactsActivity.theme = 0;
					Toast.makeText(SettingsActivity.this, "Dark Theme Saved", Toast.LENGTH_SHORT).show();
					startActivity(i);
				}
				
				
				
				
				
				
			}
		});
		
	}
//	public void onCheckedChanged(RadioGroup group, int checkedId)
//	{
//
//		Intent i = new Intent(this, ContactsActivity.class);
//		switch(checkedId)
//		{
//			case R.id.radio0:
//				ContactsActivity.theme = 0;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//			case R.id.radio1:
//				ContactsActivity.theme = 1;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//			case R.id.radio2:
//				ContactsActivity.theme = 2;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//		}
//	}
	
//	public void onClick(View v)
//	{
//		Intent i = new Intent(this, ContactsActivity.class);
//		switch(checkedRadioButton)
//		{
//			case R.id.darkThemeRadio:
//				ContactsActivity.theme = 0;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//			case R.id.lightThemeRadio:
//				ContactsActivity.theme = 1;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//			case R.id.matrixThemeRadio:
//				ContactsActivity.theme = 2;
//				System.out.println(ContactsActivity.theme);
//		    	startActivity(i);
//				break;
//		}
//	}

}
